﻿using System;
using System.Configuration;
using System.Web.Configuration;

namespace VioletDevelopmentLaboratory.Net.Web.Configuration
{
	public sealed class AppSettingsSectionManager : ConfigurationManagerBase
	{
		private AppSettingsSection section;

		public AppSettingsSectionManager()
		{
			this.section = (AppSettingsSection)base.GetConfigurationSection("appSettings");
		}

		public void Clear()
		{
			this.section.Settings.Clear();

			this.Save();
		}

		public void Add(string key, string value)
		{
			this.section.Settings.Add(key, value);

			this.Save();
		}

		public void Modify(string key, string value)
		{
			this.section.Settings[key].Value = value;

			this.Save();
		}

		public void Remove(string key)
		{
			this.section.Settings.Remove(key);

			this.Save();
		}

		public KeyValueConfigurationElement GetKeyValueConfigurationElement(string key)
		{
			return this.section.Settings[key];
		}

		public KeyValueConfigurationCollection GetKeyValueConfigurationCollection()
		{
			return this.section.Settings;
		}
	}
}